package structure;
/*
 * 循环队列 非循环队列比这个简单
 */
public class Queue {

	private static final int maxSize = 30;
	int[] Data = new int[maxSize];
	int front;
	int rear;

	public Queue() {
		this.front = -1;
		this.rear = -1;
	}

	public void addQ(int item) {
		if (this.isFull()) {
			System.out.println("队列已满");
			return;
		} else {
			this.rear = (this.rear + 1) % maxSize;
			this.Data[this.rear] = item;
		}
	}
	
	public int deleteQ() {
		if(this.isEmpty()) {
			System.out.println("队列空");
			return Integer.MAX_VALUE;
		}else {
			this.front = (this.front + 1) % maxSize;
			return this.Data[this.front];
		}
	}
	
	public boolean isEmpty() {
		if(this.front == this.rear) {
			return true;
		}else {
			return false;
		}
	}
	
	public boolean isFull() {
		if((this.rear + 1) % maxSize == this.front) {
			return true;
		}else {
			return false;
		}
	}
}
